#include "GenInitSequenceCommand.h"
#include "HD44780AnalyzerSettings.h"
#include "IHD44780.h"


void GenInitSequenceCommand::Generate()
{
    if ( NULL == mSettings || NULL == mInstructionList )
        return;

   IHD44780* Instruction = (*mInstructionList)[ mSettings->GetOperationMode() ];
   Instruction->WaitInMillis( 50 );
   Instruction->Mode( IHD44780::INTERFACE_BITS8 , IHD44780::DISPLAY_LINES2, IHD44780::FONT5X8 );
   Instruction->WaitInMillis( 10 );
   Instruction->Mode( IHD44780::INTERFACE_BITS8 , IHD44780::DISPLAY_LINES2, IHD44780::FONT5X8 );
   Instruction->WaitInMicros( 150 );
   Instruction->Mode( IHD44780::INTERFACE_BITS8 , IHD44780::DISPLAY_LINES2, IHD44780::FONT5X8 );
   Instruction->WaitInMicros( 100 );
   Instruction->Mode( mSettings->GetOperationMode() == HD44780AnalyzerSettings::BITS7 ? IHD44780::INTERFACE_BITS4 : IHD44780::INTERFACE_BITS8 , IHD44780::DISPLAY_LINES2, IHD44780::FONT5X8 );
   Instruction->CheckBusyFlagAsPulse();
   Instruction->Display(IHD44780::DISPLAY_OFF, IHD44780::CURSOR_OFF, IHD44780::BLINKING_OFF );
   Instruction->CheckBusyFlagAsPulse();
   Instruction->ClearDisplay();
   Instruction->CheckBusyFlagAsPulse();
   Instruction->EntryMode( IHD44780::CURSOR_INCREMENT, IHD44780::DONOT_SHIFT_DISPLAY );
   Instruction->CheckBusyFlagAsPulse();
}

